# coding=utf-8
# 本题为考试多行输入输出规范示例，无需提交，不计分。
import math
import sys

"""
跳马，而且相邻两个格子不能同色。
有蓝色和红色两种颜色。
"""


def getRes(world_map, input_location, record):
    record[input_location[0]][input_location[1]] = 1
    this_color = world_map[input_location[0]][input_location[1]]
    for next_i, next_j in [
        [input_location[0] - 1, input_location[1] - 2],
        [input_location[0] - 1, input_location[1] + 2],
        [input_location[0] + 1, input_location[1] - 2],
        [input_location[0] + 1, input_location[1] + 2],
        [input_location[0] - 2, input_location[1] - 1],
        [input_location[0] - 2, input_location[1] + 1],
        [input_location[0] + 2, input_location[1] - 1],
        [input_location[0] + 2, input_location[1] + 1],
    ]:
        if 0 <= next_i < len(world_map) and 0 <= next_j < len(world_map[0]):
            if world_map[next_i][next_j] != this_color:
                dfs(world_map, [next_i, next_j], record)
    count = 0
    for i in range(len(record)):
        for j in range(len(record[0])):
            count += record[i][j]

    return count


def dfs(world_map, input_location, record):
    if record[input_location[0]][input_location[1]] == 1:
        return

    record[input_location[0]][input_location[1]] = 1
    this_color = world_map[input_location[0]][input_location[1]]
    for next_i, next_j in [
        [input_location[0] - 1, input_location[1] - 2],
        [input_location[0] - 1, input_location[1] + 2],
        [input_location[0] + 1, input_location[1] - 2],
        [input_location[0] + 1, input_location[1] + 2],
        [input_location[0] - 2, input_location[1] - 1],
        [input_location[0] - 2, input_location[1] + 1],
        [input_location[0] + 2, input_location[1] - 1],
        [input_location[0] + 2, input_location[1] + 1],
    ]:
        if 0 <= next_i < len(world_map) and 0 <= next_j < len(world_map[0]):
            if world_map[next_i][next_j] != this_color:
                dfs(world_map, [next_i, next_j], record)
    return


if __name__ == "__main__":
    # 读取第一行的n
    line = sys.stdin.readline().strip()
    n, m = list(map(int, line.split()))
    world_map = []
    for _ in range(n):
        line = sys.stdin.readline().strip()
        #  value = list(map(str, line.split()))
        value = list(line.split())
        tmp_value = []
        for char in value[0]:
            tmp_value.append(char)
        world_map.append(tmp_value)
    line = sys.stdin.readline().strip()
    input_location = list(map(int, line.split()))
    record = [[0 for _ in range(m)] for _ in range(n)]

    #  print(world_map, input_location)
    #  print(record)
    res = getRes(world_map, input_location, record)
    print(res)
